﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iHub
{
    public partial class payrolldate : Form
    {
        private PayrollManager paym = new PayrollManager();
        private DateTime start;
        private DateTime end;

        public payrolldate()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Date_Closing);
        }

        private void Date_Closing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                main.form.Enabled = true;
            }
        }

        private void selectdate_Click(object sender, EventArgs e)
        {
            start = startdate.Value;
            end = enddate.Value;

            if ((end - start).TotalDays > 6)
            {
                main.form.Enabled = true;
                main.form.getPList(start, end);
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Date Range must be 7 days or more", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
    }
}
